one.randomization = function(df_province_match, df_province, df_delegate_raw) {
  df_province_match$treat = 0
  idx_treat = sample(1:nrow(df_province_match), size=12)
  df_province_match[idx_treat, 'treat'] = 1
  match_result = GenMatch(Tr=df_province_match$treat, X=df_province_match[,covariates_for_balance], 
                          M=4, replace=F, ties=F, caliper=10, wait.generations=10, verbose=F, print.level=0)
  
  df_province_match[unique(match_result$matches[,1]), 'group'] = 1
  idx_group2 = match_result$matches[,2][seq(1, nrow(match_result$matches), by=2)]
  df_province_match[idx_group2, 'group'] = 2
  idx_group3 = match_result$matches[,2][seq(2, nrow(match_result$matches), by=2)]
  df_province_match[idx_group3, 'group'] = 3
  
  df_province = merge(df_province, subset(df_province_match, select=c(Province,group)), by='Province')
  df_province = subset(df_province_raw, Province %in% c('Dong Nai','Ha Noi','TP HCM')) %>%
    .[,colnames(df_province)[-ncol(df_province)]] %>%
    arrange(Province) %>%
    mutate(group=1:3) %>%
    rbind(df_province, .)
  
  df_delegate_survey = merge(df_delegate_raw_survey, subset(df_province, select=c(Province,group)), by='Province') %>%
    subset(select=-c(Prop.Citizen,Prop.Firm))
  idx_group2 = which(df_delegate_survey$group==2)
  idx_group2_control = sample(idx_group2, size=floor(length(idx_group2)/2), replace=F)
  idx_group2_treat = setdiff(idx_group2, idx_group2_control)
  idx_group2_citizen = sample(idx_group2_treat, size=floor(length(idx_group2_treat))/2, replace=F)
  idx_group2_firm = setdiff(idx_group2_treat, idx_group2_citizen)
  idx_group3 = which(df_delegate_survey$group==3)
  idx_group3_citizen = sample(idx_group3, size=floor(length(idx_group3)/2), replace=F)
  idx_group3_firm = setdiff(idx_group3, idx_group3_citizen)
  
  df_delegate_survey$treat = 'control'
  df_delegate_survey[c(idx_group2_citizen, idx_group3_citizen), 'treat'] = 'citizen'
  df_delegate_survey[c(idx_group2_firm, idx_group3_firm), 'treat'] = 'firm'
  df_delegate_survey = subset(df_delegate_survey, !is.na(Treatment), select=c(ID, treat, Province, Missing)) %>%
    mutate(Citizen=as.integer(mapvalues(treat, c('control','citizen','firm'), c(0,1,0))),
           Firm=as.integer(mapvalues(treat, c('control','citizen','firm'), c(0,0,1))))
  ddply(df_delegate_survey, 'Province', function(x) data.frame(Prop.Citizen=mean(x$Citizen), Prop.Firm=mean(x$Firm)) ) %>%
    merge(df_delegate_survey, ., by='Province') %>%
    mutate(Iteration=ii)
}
